#!/bin/sh

# Part of Zombie Navigator
# Copyright © 2015  Zombie Navigator Developers

dir="`dirname "$0"`"
dir="`cd "$dir";pwd`"
cd "$dir/src"

if [ -x "$1" ] && [ -f "$1" ] ; then
	JPM_FIREFOX_BINARY="$1"
elif [ -x "$JPM_FIREFOX_BINARY" ] && [ -f "$JPM_FIREFOX_BINARY" ] ; then
	JPM_FIREFOX_BINARY="$JPM_FIREFOX_BINARY"
elif which firefox >/dev/null 2>&1 ; then
	JPM_FIREFOX_BINARY="`which firefox`"
elif [ -x "$HOME/.local/bin/firefox" ] ; then
	JPM_FIREFOX_BINARY="$HOME/.local/bin/firefox"
	
elif [ -x "$HOME/bin/firefox" ] ; then
	JPM_FIREFOX_BINARY="$HOME/bin/firefox"
	
elif [ -x "/usr/local/bin/firefox" ] ; then
	JPM_FIREFOX_BINARY="/usr/local/bin/firefox"
	
elif [ -x "/usr/bin/firefox" ] ; then
	JPM_FIREFOX_BINARY="/usr/bin/firefox"
	
elif [ -x "/Applications/Firefox.app/Contents/MacOS/firefox" ] ; then
	# OS/X
	JPM_FIREFOX_BINARY="/Applications/Firefox.app/Contents/MacOS/firefox"
	
elif [ -x "$HOME/Applications/Firefox.app/Contents/MacOS/firefox" ] ; then
	# OS/X, per user
	
	JPM_FIREFOX_BINARY="$HOME/Applications/Firefox.app/Contents/MacOS/firefox"
	
fi

if [ "$JPM_FIREFOX_BINARY" ] ; then
	export JPM_FIREFOX_BINARY
fi


echo "Please ignore JPM warnings about the 'sember' (if any)" >&2
echo "Because we use '~' for prereleases (for consistence with GNU/Linux conventions)" >&2

if [ -t 1 ] ; then
	../bin/run "$JPM_FIREFOX_BINARY" | egrep -v 'semver|^\s*$|semantic|versioning rules|values indicating major,|^"1\.4\.56"|^"0\.0\.1"$|^"1\.0\.0rc4"$'
else
	../bin/run "$JPM_FIREFOX_BINARY"
fi


# vim: ts=4 noet ai

